package com.hainatong.shiphelper.login.view;


import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import com.blankj.utilcode.util.ObjectUtils;
import com.blankj.utilcode.util.StringUtils;
import com.gyf.immersionbar.ImmersionBar;
import com.hainatong.shiphelper.Constants;
import com.hainatong.shiphelper.R;
import com.hainatong.shiphelper.databinding.LayoutFireDialogBinding;
import com.hainatong.shiphelper.mainhome.ComFragmentActivity;
import com.hainatong.shiphelper.utils.GsonUtil;
import com.hainatong.mvvmbase.base.BaseMvvmActivity;
import com.hainatong.mvvmbase.base.NoViewModel;

public class DialogActivity extends BaseMvvmActivity<LayoutFireDialogBinding, NoViewModel>
{
    public static String YANXI_DIALOG_TAG = "DialogActivity";

    private String yanxiBean;

    public static void startByParam(Activity mContext, String yanxiInfo )
    {
        Bundle bundle = new Bundle();
        bundle.putString(YANXI_DIALOG_TAG, GsonUtil.obj2json( yanxiInfo ));
        start(mContext, bundle, false);
    }

    public static void start(Activity mContext, Bundle bundle)
    {
        start(mContext, bundle, false);
    }

    public static void start(Activity mContext, Bundle bundle, boolean isFinish)
    {
        Intent intent = new Intent();
        intent.setClass(mContext, DialogActivity.class);
        if (bundle != null) intent.putExtra(mContext.getPackageName(), bundle);
        mContext.startActivity(intent);
        if (isFinish)
        {
            mContext.finish();
        }
    }

    public Bundle getBundle()
    {
        if (getIntent() != null && getIntent().hasExtra(getPackageName()))
            return getIntent().getBundleExtra(getPackageName());
        else
            return null;
    }

    @Override
    protected int getLayoutId()
    {
        return R.layout.layout_fire_dialog;
    }

    @Override
    protected int getBindingVariable() {
        return 0;
    }

    @Override
    protected void initView()
    {
        ImmersionBar.with(this).init();
        //StatusBarUtils.setStatusBarColor(this, Color.parseColor("#73000000"));

        Bundle bundle = getBundle();
        if(ObjectUtils.isNotEmpty( bundle ))
        {
            String infoStr = bundle.getString(YANXI_DIALOG_TAG ,"");
            if(!StringUtils.isEmpty( infoStr ))
            {
                yanxiBean = GsonUtil.json2Obj( infoStr , String.class );
            }
        }

        viewDataBinding.btnClose.setOnClickListener( v -> {

            finish();

        } );

        viewDataBinding.btnDetail.setOnClickListener( v -> {

            ComFragmentActivity.startViewByParam(this, Constants.VIEW_YANXI_STEP_DETAIL,"YanxiBean",true);

        } );

    }

    @Override
    protected void initData()
    {

    }

    @Override
    protected void onRetryBtnClick() {

    }

    @Override
    public void onBackPressed()
    {
        return;
    }
}
